{% extends 'base.html' %}
{% load static %}

{% block title %}我的活动 - 本地有约{% endblock %}

{% block content %}
<div class="container">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 style="font-size: 40px;">我的活动</h1>
        <a href="{% url 'activities:activity_create' %}" class="btn btn-primary">
            <i class="bi bi-plus-circle"></i> 创建新活动
        </a>
    </div>

    {% if activities %}
    <div class="card shadow">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-hover">
                    <thead>
                        <tr>
                            <th>活动标题</th>
                            <th>分类</th>
                            <th>开始时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for activity in activities %}
                        <tr>
                            <td>
                                <a href="{% url 'activities:activity_detail' activity.id %}" class="text-decoration-none">
                                    {{ activity.title }}
                                </a>
                            </td>
                            <td>{{ activity.category.name }}</td>
                            <td>{{ activity.start_time|date:"Y-m-d H:i" }}</td>
                            <td>
                                <span class="badge 
                                    {% if activity.status == 'approved' %}
                                        bg-success
                                    {% elif activity.status == 'pending' %}
                                        bg-warning
                                    {% elif activity.status == 'rejected' %}
                                        bg-danger
                                    {% elif activity.status == 'completed' %}
                                        bg-secondary
                                    {% endif %}">
                                    {{ activity.get_status_display }}
                                </span>
                            </td>
                            <td>
                                <a href="{% url 'activities:activity_edit' activity.id %}" class="btn btn-sm btn-outline-primary me-2">
                                    <i class="bi bi-pencil"></i> 编辑
                                </a>
                                <a href="{% url 'activities:activity_detail' activity.id %}" class="btn btn-sm btn-outline-info">
                                    <i class="bi bi-eye"></i> 查看
                                </a>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    {% else %}
    <div class="alert alert-info">
        您还没有创建任何活动，点击上方“创建新活动”开始吧！
    </div>
    {% endif %}
</div>
{% endblock %}